layui.define(['jquery','form'], function(exports){
    var $ = layui.jquery;
    var form = layui.form
    var dictJson = {
        "status":[[1,"正常"],[2,"禁用"]],
        "yesNot":[[1,"是"],[2,"否"]],
        "menuType":[[1,"模块"],[2,"功能"],[3,"按钮"]],
        "deptType":[[1,"总公司"],[2,"子公司"],[3,"部门"],[4,"团队"]],
        "deptServiceType":[[1,"销售"],[2,"工商"],[3,"会计"],[4,"商标"],[5,"财务"],[6,"人事"]],
        "sex":[[1,"男"],[2,"女"],[3,"其他"]],
        "sex":[["1","一般"],["2","小规模"]],
    };
    var obj = {
        options:function(name){
            var list = dictJson[name];
            if(!list){
                return null;
            }
            return list;
        },
        setSelect:function (id,name,defaultVal) {
            $("#"+id).empty();
            $("#"+id).append(new Option("请选择",""));
            var list = obj.options(name);
            if(!list){
                return;
            }
            $.each(list,function(index,item){
                var option = new Option(item[1],item[0]);
                if(item[0]==defaultVal){
                    option.selected=true;
                }
                $("#"+id).append(option)
            });
            form.render("select");
        },
        showName:function (name,val) {
            var list = obj.options(name);
            if(!list){
                return '';
            }
            var html = '';
            $.each(list,function(index,item){
                if(item[0]==val){
                    html = item[1]
                    return;
                }
            });
            return html;
        },
    };
    //输出接口
    exports('dict', obj);
});